package mobi.greenplate.client.connect;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.message.BasicHeader;

/**
 *
 * @author dmakariev
 */
class GetTemplate extends DefaultTemplate {

    GetTemplate(HttpClientTemplateContext context) {
        super(context);       
    }

    public int execute(final HttpClient httpClient) throws Exception {
        final HttpGet httpget = new HttpGet(getContext().getUrl());
        httpget.setParams(getContext().getParams());
        httpget.setHeader(new BasicHeader("Accept", "application/xml"));

        final HttpResponse response = httpClient.execute(httpget);
       
        return handleResponse(response, getContext().getResponseHandler());
    }
}
